<template>
  <div class="main_pass">
    <div class="tit tac bg-fff container">{{$t('merchantex.passwd_jymm')}}</div>

    <ul class="line bg-fff">
      <li>
        <div class="val">
          <input type="password"  name=""
                 v-model="password"
                 :placeholder="$t('merchantex.passwd_enter_jymm')"
                 maxlength="16"
          >
        </div>
      </li>
    </ul>
    <div class="container">
      <div class="link tar" @click="pw_link()">{{$t('merchantex.asset_wjmm')}}</div>
    </div>



    <div class="container">
      <button class="btn" @click="handleSubmit()">{{btn}}</button>
    </div>


  </div>
</template>
<script>
export default {
  props: {
    titles: {
      type: String,
      default: function(){
        return this.$t('merchantex.passwd_jymm');
      },
    },
    is_pass:{
      type: Boolean,
      default: false
    },
    btn: {
      type: String,
      default: function(){
        return this.$t('merchantex.openstore_ok');
      },
    },
  },
  watch: {
    is_pass(v,c){
      if(!v){
        this.password = ''
      }
    }
  },
  data() {
    return {
      password: "",
    };
  },
  created() {
  },
  methods: {
    pw_link(){
      if (this.$store.state.isApp) {
        let appResult = {
          code: this.CMD.app.RESET_ASSERT_PASSWD,
          data: {}
        };
        this.common.callBackApp(appResult);
        return;
      }
      this.$router.push({
        path: "/mearch_asset/verify_login_pwd",
        query: {}
      });
    },
    handleSubmit() {
      if(this.password == ''){
        //this.$toast('密码不能为空');
        this.$toast(this.$t('merchantex.passwd_tip1'));
        return
      }
      let data = {
        password: this.$md5(this.password),
      };
      this.$post(this.URL.mearchant_all.verify_Password, data).then(res => {
        if (res.code == 0) {
          if(res.data){
            this.$emit("callback",data);
          }else{
            this.$toast(this.$t('toast.password_error'));
          }

        }else{
          this.$toast(res.message);
        }
      });

    },
  },
};
</script>
<style lang="less" scoped>
#app {
  .tit {
    height: 1rem;
    line-height: 1rem;
    font-size: .3rem;
    font-weight: 400;
    color: #14191f;
  }
  .line {
    padding: 0 .3rem;
    li {
      padding: .3rem 0 0 0;
    }
    .val {
      input {
        height: 1.1rem;
        width: 100%;
        padding: 0 .2rem;
        background: #ffffff;
        border: .02rem solid #dddddd;
        border-radius: .08rem;
        font-size: .32rem;
      }
    }
  }
  .link {
    font-weight: 400;
    color: #0091ff;
    line-height: .42rem;
    padding: .2rem 0 .5rem 0;
  }
}
</style>
